package licode.unisop.types.dp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AusProperties {
    private List<String> rs;
    private List<String> rg;
    private List<String> ps;
    private List<String> pg;

    private List<AusUrlItem> urls;
    private List<String> fms;

    private Map<String, String> pm;

    public AusProperties() {
        rs = new ArrayList<>();
        rg = new ArrayList<>();
        ps = new ArrayList<>();
        pg = new ArrayList<>();
        urls = new ArrayList<>();
        fms = new ArrayList<>();
        pm = new HashMap<>();
    }

    public boolean isEmpty() {
        return ((null == fms || fms.size() == 0) &&
                (null == rs || rs.size() == 0) &&
                (null == rg || rg.size() == 0) &&
                (null == ps || ps.size() == 0) &&
                (null == pg || pg.size() == 0) &&
                (null == urls || urls.size() == 0) &&
                (null == pm || pm.size() == 0));
    }

    private boolean isEmptyList(List<String> emList) {
        return (emList != null && emList.size() == 0);
    }

    public void normalizeEmpty() {
        if (isEmptyList(fms)) {
            fms = null;
        }

        if (isEmptyList(rs)) {
            rs = null;
        }

        if (isEmptyList(rg)) {
            rg = null;
        }

        if (isEmptyList(ps)) {
            ps = null;
        }

        if (isEmptyList(pg)) {
            pg = null;
        }

        if (urls != null && urls.size() == 0) {
            urls = null;
        }

        if (pm != null && pm.size() == 0) {
            pm = null;
        }
    }

    public List<String> getRs() {
        return rs;
    }

    public void setRs(List<String> roleIds) {
        this.rs = roleIds;
    }

    public List<String> getRg() {
        return rg;
    }

    public void setRg(List<String> rg) {
        this.rg = rg;
    }

    public List<String> getPs() {
        return ps;
    }

    public void setPs(List<String> permitCodes) {
        this.ps = permitCodes;
    }

    public List<String> getPg() {
        return pg;
    }

    public void setPg(List<String> pg) {
        this.pg = pg;
    }

    public List<AusUrlItem> getUrls() {
        return urls;
    }

    public void setUrls(List<AusUrlItem> urls) {
        this.urls = urls;
    }

    public List<String> getFms() {
        return fms;
    }

    public void setFms(List<String> fms) {
        this.fms = fms;
    }

    public Map<String, String> getPm() {
        return pm;
    }

    public void setPm(Map<String, String> pm) {
        this.pm = pm;
    }
}
